//
//  FLMakeAgainView.m
//  FeeLing
//
//  Created by 乔光玉 on 2019/1/11.
//  Copyright © 2019年 大仙儿飘. All rights reserved.
//

#import "FLMakeAgainView.h"
@interface FLMakeAgainView()<UITextFieldDelegate>
{
    UIView * klsbackView;
    UITextField *klstextField ;
    UIButton *klscancelButton;
    UIButton *klstureButton;
}
@end
@implementation FLMakeAgainView


-(void)initView{
    self.userInteractionEnabled = YES;
    
    UIView * view =[[UIView alloc]initWithFrame:CGRectMake(0, 0, SCREENWIDTH, SCREENHEIGHT)];
    view.backgroundColor = [UIColor clearColor];
    
    [self addSubview:view];
    
    
   
    
    
    klsbackView = [[UIView alloc]initWithFrame:CGRectMake(SCREENWIDTH/2-135, 221, 270, 197)];
    klsbackView.layer.borderWidth = 2;
    klsbackView.layer.borderColor = [UIColor colorWithRed:255/255.0 green:255/255.0 blue:255/255.0 alpha:1.0].CGColor;
    
    klsbackView.backgroundColor = [UIColor colorWithRed:255/255.0 green:255/255.0 blue:255/255.0 alpha:1.0];
    klsbackView.layer.cornerRadius = 14;
    klsbackView.clipsToBounds = YES;
    klsbackView.userInteractionEnabled = YES ;
    [self addSubview:klsbackView];
    
    
    UILabel *shurulabel = [[UILabel alloc] init];
    shurulabel.frame = CGRectMake(0,25,klsbackView.width,30);
    shurulabel.numberOfLines = 0;
    shurulabel.textAlignment = NSTextAlignmentCenter;
    shurulabel.text = NSLocalizedString(@"chongmingminga", nil);
    shurulabel.textColor =[UIColor colorWithRed:0/255.0 green:0/255.0 blue:0/255.0 alpha:1];
    shurulabel.font =[UIFont fontWithName:@"PingFangSC-Medium" size: 22];
    [klsbackView addSubview:shurulabel];
    
    
    klstextField= [[UITextField alloc] initWithFrame:CGRectMake(20, 80, klsbackView.width-40, 38)];
    klstextField.placeholder = NSLocalizedString(@"pleaserut", nil);
    klstextField.textColor = [UIColor colorWithHexString:@"#999999"];
    klstextField.font =  [UIFont fontWithName:@"PingFangSC-Regular" size:12];
    klstextField.textAlignment = NSTextAlignmentLeft;
    klstextField.borderStyle = UITextBorderStyleRoundedRect;
    klstextField.layer.borderColor = [UIColor colorWithHexString:@"#E5E5E5"].CGColor;
    klstextField.layer.borderWidth = 2;
    klstextField.layer.cornerRadius = 4;
    klstextField.keyboardType = UIKeyboardTypeDefault;
    klstextField.delegate = self;
    klstextField.returnKeyType =UIReturnKeyDefault;
    [klsbackView addSubview:klstextField];
    
    
    
    klscancelButton= [UIButton buttonWithType:UIButtonTypeCustom];
    klscancelButton.layer.borderWidth = 2;
    klscancelButton.layer.borderColor = [UIColor colorWithHexString:@"#E5E5E5"].CGColor;
    
    klscancelButton.backgroundColor = [UIColor colorWithHexString:@"#E5E5E5"];
    klscancelButton.layer.cornerRadius = 8;
    [klscancelButton setTitleColor:[UIColor colorWithHexString:@"#666666"] forState:UIControlStateNormal];
    klscancelButton.titleLabel.font = [UIFont fontWithName:@"PingFangSC-Medium" size: 16];
    klscancelButton.frame= CGRectMake(17, 137 ,114, 40);
    
    [klscancelButton setTitle:NSLocalizedString(@"cancal", nil) forState:UIControlStateNormal];
    
    [klscancelButton addTarget:self action:@selector(cancelButtonclick:) forControlEvents:UIControlEventTouchUpInside];
    [klsbackView addSubview:klscancelButton];
    
    
    
    
    
    
    klstureButton= [UIButton buttonWithType:UIButtonTypeCustom];
    CAGradientLayer *gl = [CAGradientLayer layer];
    gl.frame = CGRectMake(0,0,114,40);
    gl.startPoint = CGPointMake(0, 0);
    gl.endPoint = CGPointMake(1, 1);
    gl.colors = @[(__bridge id)[UIColor colorWithRed:124/255.0 green:139/255.0 blue:248/255.0 alpha:1.0].CGColor, (__bridge id)[UIColor colorWithRed:74/255.0 green:88/255.0 blue:233/255.0 alpha:1.0].CGColor];
    gl.locations = @[@(0), @(1.0f)];
    gl.cornerRadius = 8;
    [klstureButton.layer insertSublayer:gl atIndex:0];
    [klstureButton setTitleColor:[UIColor colorWithHexString:@"#FFFFFF"] forState:UIControlStateNormal];
    klstureButton.titleLabel.font = [UIFont fontWithName:@"PingFangSC-Medium" size: 16];
    klstureButton.frame= CGRectMake(klsbackView.width-18-114, 137 ,114, 40);
    
    [klstureButton setTitle:NSLocalizedString(@"ture", nil) forState:UIControlStateNormal];
    
    [klstureButton addTarget:self action:@selector(tureButtonclick:) forControlEvents:UIControlEventTouchUpInside];
    [klsbackView addSubview:klstureButton];
    
    
}
-(instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self)
    {
        [self initView];
    }
    return self;
}


-(void)cancelButtonclick:(UIButton *)button{
    
    
    self.cancelBlock(button);
    
    
}
-(void)tureButtonclick:(UIButton *)button{
    
    
    self.tureBlock(button,klstextField.text);
    
    
}
- (BOOL)textFieldShouldReturn:(UITextField *)textField
{
       
    
    [klstextField resignFirstResponder];
    
    
    return YES;
    
}
-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
    [klstextField resignFirstResponder];
    
}


@end
